#conding:utf-8
import json
import requests
import os,sys
class RunMethod:
    def post_main(self,url,data,header=None):
        res=None
        if header !=None:
            res = requests.post(url=url, data=json.dumps(data), headers=header)
            # print(res.status_code)
            # res=requests.post(url=url, data=json.dumps(data), headers=header).json()
            # res.status()
        else:
            res=requests.post(url=url,data=json.dumps(data))

            # print(res.status_code)
        #     返回响应数据数据json
        # return res.json()
        return res.json()

    def get_main(self,url,data,header):
        res = None
        if header != None:
            # res = requests.get(url=url, data=data, headers=header)
            res = requests.get(url=url, data=data, headers=header).json()
        else:
            res = requests.get(url=url, data=data)
            # res = requests.get(url=url, data=data).json()
        return res
    def run_main(self,method,url,data=None,header=None):
        res=None
        if method=='post':
            res=self.post_main(url,data,header)
        else:
            res=self.get_main(url,data,header)
        return res
        # return json.dumps(res)


if __name__=='__main__':
    method='post'
    url1 = 'http://iosapi.jiahuiku.cn/api/auth/v1/token/mobile/v2'
    mtthod = 'post'
    # header = {'Content-type':'application/json;charset=UTF-8'}
    data = {
        "password": "12345678",
        "systemType": "1",
        "mobile": "15107642972",
        "src": "mobile"
    }
    method='get'
    url='http://iosapi.jiahuiku.cn/api/user/v1/briefInfo?id=200513490216230224'
    header={
        "Content-type": "application/json",
        "Authorization": "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiIzODI3IiwidXNlcklkIjoiMjg5NzM1OTg3MTQ3MjE4OTQ0IiwibmFtZSI6Im1vYmlsZSIsImV4cCI6Mzc4Njg2MDYyOH0.HQEWkgypzaGl-p3REHRlCsojgDgTbQWoIv4p37vfAUkyhIiQQWQWY1FXgAF7WT4TOlpi1j58aOWeveVWTt2R6DNjU4rYeuPtKphpMBfSxIqYkiO470YYTXWhEbx_fNt_5Ye38L6TT3NnsnSDhov6_ypm1JJr8C9B0my6i68VfmE"
    }
    oper=RunMethod()
    # json.dumps()
    print(type(oper.run_main(method,url,data,header)))
    print(oper.run_main(method,url,data,header))
    print(type(oper.run_main(mtthod,url1,data,header)))
    print(oper.run_main(mtthod,url1,data,header))
    # print(type(json.loads(oper.run_main(mtthod,url1,data,header),indent=2,sort_keys=True,ensure_ascii=False)))


